{include file="common/mainHead"/}
<div class="admin-main fadeInUp animated">
    <blockquote class="layui-elem-quote">
        <a href="{:url('groupAdd')}" class="layui-btn layui-btn-small">
            <i class="fa fa-plus"></i> {:lang('add')}会员组
        </a>
    </blockquote>
    <fieldset class="layui-elem-field">
        <legend>会员组{:lang('list')}</legend>
        <form class="layui-form layui-form-pane">
            <div class="layui-field-box table-responsive">
                <table class=" layui-table table-hover">
                    <thead>
                    <tr>
                        <th>{:lang('id')}</th>
                        <th>名称</th>
                        <th>满足积分条件</th>
                        <th>{:lang('order')}</th>
                        <th>{:lang('action')}</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="list" id="v"}
                    <tr>
                        <td>{$v.level_id}</td>
                        <td>{$v.level_name}</td>
                        <td>{$v.bomlimit}-{$v.toplimit}</td>
                        <td><input name="{$v.level_id}" value=" {$v.sort}" class="list_order"/></td>
                        <td>
                            <a href="{:url('groupEdit',['level_id'=>$v['level_id']])}" class="layui-btn layui-btn-mini">{:lang('edit')}</a>
                            <a href="javascript:;" onclick="return del('{$v.level_id}')" class="layui-btn layui-btn-mini layui-btn-danger">{:lang('del')}</a>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="5">
                            <button type="button" class="layui-btn  layui-btn-small" lay-submit="" lay-filter="sort">{:lang('order')}</button>
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </form>
    </fieldset>
    <div class="admin-table-page">
        <div id="page" class="page">
            {$page}
        </div>
    </div>
</div>
{include file="common/mainFoot"/}
<script>
    layui.use(['form', 'layer'], function() {
        var form = layui.form(), layer = layui.layer;
    });
    function del(id) {
        layer.confirm('你确定要删除吗？', {icon: 3}, function (index) {
            layer.close(index);
            window.location.href = "{:url('groupDel')}?level_id=" + id;
        });
    }
    //排序提交
    layui.use(['form', 'layer'], function() {
        var form = layui.form(),layer = layui.layer;
        form.on('submit(sort)', function(data){
            $.post("{:url('groupOrder')}",data.field,function(res){
                if(res.code > 0){
                    layer.msg(res.msg,{time:1000,icon:1},function(){
                        location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            })
        });
    });
</script>